﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using sharpTV.Windows;

namespace sharpTV.Windows
{
	public partial class sharpTV : Form
	{
		public sharpTV()
		{
			InitializeComponent();
			this.InitializeUI();
		}

		private void InitializeUI()
		{
			this.Text = string.Format("{0} v.{1}", "sharpTV", Application.ProductVersion);
			this.ProgressBar.Visible = false;
		}

		private void sharpTV_Load(object sender, EventArgs e)
		{
			this.ProgressBar.Repositioning();

		}

		private void sharpTV_Resize(object sender, EventArgs e)
		{
			this.ProgressBar.Repositioning();
		}

		#region Menu Handlers

		private void Menu_Close_Click(object sender, EventArgs e)
		{
			this.Close();
		}
		private void Menu_OpenChannel_Click(object sender, EventArgs e)
		{
			OpenChannel openChannel = new OpenChannel();
			openChannel.ShowDialog();
		}

		#endregion

		private void sharpTV_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (e.CloseReason == CloseReason.UserClosing)
			{
				if (Application.OpenForms.Count > 1)
				{
					MessageBox.Show(this, "Chiudere tutte le finestre aperte.", "Chiusura in corso", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
					e.Cancel = true;
					return;
				}

				if (MessageBox.Show(this, "Vuoi veramente uscire da sharpTV?", "Chiusura in corso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
					e.Cancel = true;
			}
		}
	}
}
